/**
 * Title : jFamilyTree
 * Description: jFamilyTree
 * About: Designed and rewritten by Andreas Lundgren, based on the Treebolic application suite
 * Copyright:	(c) 2001-2008
 * Terms of use:see license agreement at http://treebolic.sourceforge.net/en/license.htm
 * Author: Bernard Bou
 * Company: bsys
 */
package jFamilyTree.commons;

import java.io.File;
import java.net.MalformedURLException;

/**
 * Help
 * 
 * @author Bernard Bou
 */
public class Help
{
	/**
	 * Help
	 */
	static public void help(String thisBrowser, String thisHelp)
	{
		if (!thisHelp.startsWith("file:")) //$NON-NLS-1$
		{
			File thisFolder = new File(thisHelp);
			try
			{
				thisHelp = thisFolder.toURI().toURL().toString();
			}
			catch (MalformedURLException thisException)
			{
				return;
			}
		}
		if (!thisHelp.endsWith("/")) //$NON-NLS-1$
			thisHelp += "/"; //$NON-NLS-1$
		thisHelp += "index.html"; //$NON-NLS-1$
		run(thisBrowser + " " + thisHelp ); //$NON-NLS-1$
	}

	/**
	 * Run command as separate process
	 * 
	 * @param thisCommand
	 *        command line
	 */
	static private void run(String thisCommand)
	{
		if (thisCommand != null && thisCommand != null)
		{
			try
			{
				Runtime.getRuntime().exec(thisCommand);
			}
			catch (Exception e)
			{
				System.err.println("Cannot run " + thisCommand + " " + e.toString()); //$NON-NLS-1$ //$NON-NLS-2$
			}
		}
	}
}
